const mongoose = require('mongoose');

// 使用环境变量中的MongoDB URI，如果没有则使用默认值
// const mongoURI = process.env.MONGODB_URI || "mongodb://dongningServer:wangle321@localhost:27017/dongningServer";
const mongoURI = "mongodb://localhost:27017/dongning";

console.log("正在连接数据库:", mongoURI.replace(/\/\/[^@]+@/, '//***:***@')); // 隐藏密码

mongoose.connect(mongoURI)
.then(() => {
    console.log("数据库连接成功!");
})
.catch((err) => {
    console.log("数据库连接失败!", err);
});

module.exports = {
    User: require('./Model/User'),
    Post: require('./Model/Post'),
    Comment: require('./Model/Comment'),
    ExpRecord: require('./Model/ExpRecord'),
    Message: require('./Model/Message'),
    Feedback: require('./Model/Feedback'),
    IdentityVerification: require('./Model/IdentityVerification'),
    IdentityAuditLog: require('./Model/IdentityAuditLog'),
    // Admin 模型不再使用
};